< previous page page_443 next page >

Page 443
Adding a Splash of Color
A form designed with totally battleship gray components is dull and plain. However, you can easily assign color to the form and controls on it by using the ForeColor and BackColor properties. To set these properties at designtime, you can use either a Color list or a Color Palette. To view the Color list, bring up the Properties window for a control or form and click on the ForeColor or BackColor property. The Color list is shown in Figure 19.10.
0443-01.jpg
Figure 19.10
You can set the 
ForeColor and
BackColor properties from the Color list.
Notice that the Color list has two sections: Palette and System. Palette allows you to pick specific colors, whereas System lists the colors in the current Windows color scheme. If you use System colors, changing the Windows system colors in the Display control panel makes the colors in your program change, too. Considering this point is important when you're distributing a program.
The Color Palette, shown in Figure 19.11, allows you to change foreground and background colors at the same time. To view the Color Palette, select a control or form and then choose Color Palette from the View menu.
0443-02.jpg
Figure 19.11
The color Palette box is another means
of changing 
colors at designtime.
Change colors at designtime and then look at the ForeColor or BackColor properties. Notice that they are actually represented as numbers; for example, blue is represented by &HFF0000& in hexadecimal or decimal 16711680. VB also has built-in constants for some colors, listed in Table 19.3. To set colors of objects within your program code, simply assign numbers to the ForeColor and BackColor properties, as in the following code:
Form1.ForeColor = vbYellow
Form1.BackColor = vbBlue

 
< previous page page_443 next page >